f = open('test.txt', 'w')  # 没有就创建
f.write('liuchuanzheng\nzhangsan\nlisi')
f.close()

f1 = open('test.txt', 'r')
print(f1.read())  # 读取所有
f1.close()

f2 = open('test.txt', 'r')
print(f2.readlines())  # 读取所有行，变成一个列表
f2.close()

f3 = open('test.txt', 'r')
print(f3.readline())  # 读取一行
f3.close()

f4 = open('test.txt', 'r')
# 文件对象.seek(偏移量，起始位置) 0开头 1当前 2结尾
f4.seek(2,0)
print(f4.read())
f4.close()
